﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VideoNetApplication.Common.Dao
{
    public class RecruitStudentDao
    {

        /// <summary>
        /// 学校获取
        /// </summary>
        /// <param name="schoolId"></param>
        /// <returns></returns>
        public List<V_RecruitStudent> GetRecruitBysSchoolId(int schoolId)
        {
            using (EVDBEntities edm = new EVDBEntities())
            {
                return edm.V_RecruitStudent.Where(s => s.SchoolId == schoolId && s.IsPulished == 1).OrderByDescending(s => s.ID).ToList();
            }

        }


        /// <summary>
        /// 分页获取
        /// </summary>
        /// <param name="schoolId"></param>
        /// <param name="starIndex"></param>
        /// <param name="maxRow"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public List<V_RecruitStudent> GetRecruitList(int schoolId, int starIndex, int maxRow, out int recordCount)
        {

            using (EVDBEntities edm = new EVDBEntities())
            {
                recordCount = edm.V_RecruitStudent.Where(s => s.SchoolId == schoolId && s.IsPulished == 1).Count();

                return edm.V_RecruitStudent.Where(s => s.SchoolId == schoolId&&s.IsPulished==1).OrderByDescending(s=>s.ID).Skip(starIndex - 1).Take(maxRow).ToList();

            }
        }


        public V_RecruitStudent GetRecruitById(int id)
        {
            using (EVDBEntities edm = new EVDBEntities())
            {
                return edm.V_RecruitStudent.FirstOrDefault(s => s.ID == id);
            }

        }

    }
}
